//promise 封装
const db = wx.cloud.database()
//轮播

var home = function(tables) {
	return new Promise((resolve, reject) => {
		var table = db.collection(tables)
		table.get()
			.then((res) => {
				resolve(res)
			}).catch((err) => {
				reject(err)
			})
	})
}

var homeList = function(listing,pageid) {
	return new Promise((resolve, reject) => {
		var listdata = db.collection(listing)
		.limit(6)	//每次取值几个
		.skip(pageid * 6) //从第几条数据开始取值按下标计算
		listdata.get()
			.then((res) => {
				resolve(res)
			}).catch((err) => {
				reject(err)
			})
	})
}
export {
	home,
	homeList
}
